package cn.hnu.jpa.jpaExample.bidirectional;

import java.io.Serializable;

import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.OneToOne;

@Entity
public class StuAddress implements Serializable{

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	
	private Student person;
	
	private Integer id;
	
	private String addr;

	
	
	public StuAddress() {
		super();
		// TODO Auto-generated constructor stub
	}
	
	public StuAddress(Student person, String addr) {
		super();
		this.person = person;
		this.addr = addr;
	}

	@OneToOne(cascade = {CascadeType.ALL},fetch = FetchType.LAZY,mappedBy = "addr")
	public Student getPerson() {
		return person;
	}

	public void setPerson(Student person) {
		this.person = person;
	}

	@Id @GeneratedValue(strategy = GenerationType.AUTO)
	public Integer getId() {
		return id;
	}

	public void setId(Integer id) {
		this.id = id;
	}

	public String getAddr() {
		return addr;
	}

	public void setAddr(String addr) {
		this.addr = addr;
	}
	
	
	
}
